1420A - Cubes Sorting - CodeForces Solution


math sortings *900

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define C continue
#define R return
#define B break
#define Pr pair<int,int>
#define logic(x) cout<<(x?"YES":"NO")<<"\n"
#define _ ios::sync_with_stdio(0),cout.tie(0),cin.tie(0);
using namespace std;
const int N = 2e5 + 5;
int T, n, ar[N], b[N], ans, x;
signed main()
{_
    cin >> T;
    while (T--){
        cin >> n;   ans = 0;
        for (int i = 0; i < n; i++) cin >> ar[i], ans += (i && ar[i - 1] > ar[i]);
        logic(ans != n - 1);
    }
    return 0;
}


Comments

Submit
0 Comments
More Questions

467B - Fedor and New Game
252C - Points on Line
735C - Tennis Championship
992A - Nastya and an Array
554A - Kyoya and Photobooks
79B - Colorful Field
265B - Roadside Trees (Simplified Edition)
1362C - Johnny and Another Rating Drop
1214C - Bad Sequence
1091B - New Year and the Treasure Geolocation
244A - Dividing Orange
1061C - Multiplicity
1312A - Two Regular Polygons
801A - Vicious Keyboard
510B - Fox And Two Dots
616D - Longest k-Good Segment
1604A - Era
555B - Case of Fugitive
551A - GukiZ and Contest
1399F - Yet Another Segments Subset
1371C - A Cookie for You
430B - Balls Game
1263A - Sweet Problem
1332B - Composite Coloring
254A - Cards with Numbers
215A - Bicycle Chain
1288B - Yet Another Meme Problem
1201C - Maximum Median
435A - Queue on Bus Stop
1409B - Minimum Product